<!--
 * @Author: zhoujieyu zhoujieyu_web@163.com
 * @Date: 2024-09-10 10:11:45
 * @LastEditors: zhoujieyu zhoujieyu_web@163.com
 * @LastEditTime: 2024-09-26 15:35:13
 * @FilePath: \Code\覆盖物.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>覆盖物</title>
    <link rel="stylesheet" href="./lib/styles.css" />

    <script type="text/javascript" src="./lib/aircity/ac_conf.js"></script>
    <script type="text/javascript" src="./lib/aircity/ac.min.js"></script>
    <script type="text/javascript" src="./lib/Vue3.js"></script>
  </head>
  <body>
    <div id="dom">
      <div id="player"></div>

      <div class="btn-list">
        <div onclick="goHtml('./贴花.html')" class="btn">添加贴花</div>
        <div onclick="goHtml('./视频投影.html')" class="btn">添加视频投影</div>
        <div onclick="addPanorama()" class="btn">添加全景图</div>
      </div>
    </div>

    <script type="text/javascript">
      const { createApp } = Vue
      const goHtml = url => {
        window.location.href = url
      }
      /**
       * 添加全景图
       */
      const addPanorama = async () => {
        fdapi.panorama.clear()
        await fdapi.panorama.add({
          id: 'p1',
          imagePath: '@path:第十一讲/panorama1.jpg',
          coordinate: [8005.72, 4649.484375, 17.137312011718752],
          coordinateType: 0, //坐标系类型，取值范围：0为Projection类型，1为WGS84类型，2为火星坐标系(GCJ02)，3为百度坐标系(BD09)，默认值：0
          yaw: 190, //方向
          onTerrain: true, //是否贴地，注意：设置为贴地后offset偏移量的Z轴会失效
          offset: [0, 0, 0] //偏移量
        })
        await fdapi.panorama.focus('p1')
      }

      /**
       * 初始化场景
       */
      const OnLoad = () => {
        const __DigitalTwinPlayer = new DigitalTwinPlayer(HostConfig.Player, {
          domId: 'player',
          apiOptions: {
            onReady: function () {
              fdapi.reset(1 | 2 | 4)
            }
          }
        })
      }

      /**
       * 自适应分辨率
       */
      const onResize = async () => {
        let playerView = document.getElementById('player')
        playerView.style.height = window.innerHeight + 'px'
        playerView.style.width = window.innerWidth + 'px'
      }

      const app = createApp({
        setup() {
          // 页面加载调用
          window.addEventListener('load', OnLoad, true)
          // 页面窗口变换调用
          window.addEventListener('resize', onResize, true)
          return {}
        }
      })
      app.mount('#dom')

      /**
       * 页面离开事件(离开时清除此页面的操作及重置场景)
       */
      window.onunload = function (e) {
        // 重置场景
        fdapi.reset(1 | 2 | 4)
      }
    </script>
  </body>
</html>
